home *** CD-ROM | disk | FTP | other *** search
- Path: rcogate.rco.qc.ca!usenet
- From: jds <jds@lino.com>
- Newsgroups: comp.lang.c++
- Subject: Re: C++ Gurus! Is it correct?
- Date: 4 Feb 1996 00:56:49 GMT
- Organization: Inter-Acces Communications
- Message-ID: <4f108h$3eh@rcogate.rco.qc.ca>
- References: <4eqvtg$cg5@israel-info.datasrv.co.il> <4etnju$6gn@rolaids.frco.com> <4f0n8s$a3b@news2.ios.com>
- NNTP-Posting-Host: tty24.lino.com
-
- vlad@gramercy.ios.com (Vlastimil Adamovsky) wrote:
- >
- > Jadam@tcmail.frco.com (Jim Adam) wrote:
- >
- > >In article <4eqvtg$cg5@israel-info.datasrv.co.il>, dmitry@enigma.co.il
- > >says...
- >
- > >>Is next code is correct from point of view of pure C++ ?
- >
- > >>class A
- > >>{
- > >>};
- >
- > >>class B
- > >>{
- > >>};
- >
- > >>class C : public A, public B
- > >>{
- > >>};
- >
- > >>A* pA = new C;
- > >>B* pB = new C;
- >
- > >>delete pA;
- > >>delete pB;
- >
- > >==========================
- >
- > >This is correct. However, to ensure the destructor for class
- > >C gets called correctly, class A and B both need virtual
- > >destructors.
- >
- > >E.g.,
- >
- > > class A
- > > {
- > > public:
- > > virtual ~A();
- > > };
- >
- > >And likewise for class B.
- >
- > >Jim
- >
- > I don't think the virtual destructor is necessary in this specific
- > case where you have no added data in subclasses.
-
-
- Do you think we post all our files on this newsgroup????????????????
- Jacques
- jds@lino.com
-
-